using System;
using UnityEngine;
using Unity.VisualScripting;
using GameFramework.Event;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Open UI Form")]
    [UnitSurtitle("Success")]
    public sealed class OpenUIFormSuccess : FrameworkEventUnit<OpenUIFormSuccessEventArgs>
    {
        protected override int EventId => OpenUIFormSuccessEventArgs.EventId;
        protected override string HookName => UGFHookNames.OpenUIFormSuccess;

        [DoNotSerialize] 
        [PortLabelHidden] 
        public ValueOutput UIForm { get; private set; }

        [DoNotSerialize] 
        [PortLabelHidden] 
        public ValueOutput UIFormLogic { get; private set; }
        
        [DoNotSerialize] 
        [PortLabelHidden] 
        public ValueOutput Duration { get; private set; }

        [DoNotSerialize] 
        [PortLabelHidden] 
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            UIForm = ValueOutput<UIForm>(nameof(UIForm));
            UIFormLogic = ValueOutput<UIFormLogic>(nameof(UIFormLogic));
            Duration = ValueOutput<float>(nameof(Duration));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, OpenUIFormSuccessEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(UIForm, args.UIForm);
            flow.SetValue(UIFormLogic, args.UIForm.Logic);
            flow.SetValue(Duration, args.Duration);
            flow.SetValue(UserData, args.UserData);
        }
    }
}